Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
@turf/projection
Advanced tools
@turf/projection is a module within the Turf.js library that provides functionality for projecting geographical coordinates. It allows for the conversion of coordinates between different coordinate reference systems (CRS), which is essential for various geospatial analyses and visualizations.
toMercator
Converts a GeoJSON object from geographic coordinates (longitude, latitude) to Mercator (x, y) coordinates.
const turf = require('@turf/turf');
const point = turf.point([-75.343, 39.984]);
const projected = turf.toMercator(point);
console.log(projected);
toWgs84
Converts a GeoJSON object from Mercator (x, y) coordinates to geographic coordinates (longitude, latitude).
const turf = require('@turf/turf');
const point = turf.point([0, 0]);
const projected = turf.toWgs84(point);
console.log(projected);
Proj4 is a JavaScript library for converting coordinates between different coordinate reference systems. It is highly versatile and supports a wide range of projections. Compared to @turf/projection, proj4 offers more extensive support for various CRS and is often used in more complex geospatial applications.
Converts a WGS84 GeoJSON object into Mercator (EPSG:900913) projection
Parameters
geojson
(GeoJSON | Position) WGS84 GeoJSON objectoptions
Object? Optional parameters
options.mutate
boolean allows GeoJSON input to be mutated (significant performance increase if true) (optional, default false
)Examples
var pt = turf.point([-71,41]);
var converted = turf.toMercator(pt);
//addToMap
var addToMap = [pt, converted];
Returns GeoJSON Projected GeoJSON
Converts a Mercator (EPSG:900913) GeoJSON object into WGS84 projection
Parameters
geojson
(GeoJSON | Position) Mercator GeoJSON objectoptions
Object? Optional parameters
options.mutate
boolean allows GeoJSON input to be mutated (significant performance increase if true) (optional, default false
)Examples
var pt = turf.point([-7903683.846322424, 5012341.663847514]);
var converted = turf.toWgs84(pt);
//addToMap
var addToMap = [pt, converted];
Returns GeoJSON Projected GeoJSON
This module is part of the Turfjs project, an open source module collection dedicated to geographic algorithms. It is maintained in the Turfjs/turf repository, where you can create PRs and issues.
Install this module individually:
$ npm install @turf/projection
Or install the Turf module that includes it as a function:
$ npm install @turf/turf
FAQs
turf projection module
We found that @turf/projection demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.